<?php
/**
 * Проверяет пароли на совпадение
 * 
 */
class Auth_Validate_Confirmation extends Zend_Validate_Abstract
{
    const NOT_MATCH = 'notMatch';

    /**
     * @see Zend_Validate_Abstract::$_messageTemplates
     * @var array
     */
    protected $_messageTemplates = array(
        self::NOT_MATCH => '[ERROR_PASSWORD_NOT_MATCH]'
    );

    /**
     * @see Zend_Validate_Abstract::isValid()
     * @param string $value
     * @param mixed $context
     * @return bool
     */
    public function isValid($value, $context = null)
    {
        $value = (string) $value;
        $this->_setValue($value);
        if (is_array($context)) {
            if (isset($context['password']) && ($value == $context['password'])) {
                return true;
            }
        }
        $this->_error(self::NOT_MATCH);
        return false;
    }
}